﻿using StructureMap;

using Cinema.BL;
using Cinema.BL.Interfaces;
using Cinema.Model.EF;
using Cinema.Model.Interfaces;

namespace Cinema.IoC
{
    /// <summary>
    /// A class that initializes the StructureMap IoC container ones it gets touched
    /// </summary>
    public class Settings
    {
        /// <summary>
        /// Static constructor which is executed only once in the lifecycle of the 
        /// underlying system.
        /// It is executed the first time the containing class is touched.
        /// 
        /// It initializes the StructureMap IoC container with the necessary settings 
        /// </summary>
        static Settings()
        {
            ObjectFactory.Initialize(x =>
            {
                // set up injection of the type IUnitOfWork 
                x.For<IUnitOfWork>().Use<UnitOfWork>();

                // set up injection of the type IManagerFactory
                x.For<IManagerFactory>().Use<ManagerFactory>();
            });
        }

        /// <summary>
        /// An empty method that is used to touche the Settings class, so that it
        /// executes its static constructors
        /// </summary>
        public static void Poke()
        {
        }
    }
}
